package com.coderman.controller;

import com.coderman.bean.Order;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.time.ZoneId;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by ${fanchunshuai} on 2017-6-21.
 *
 * @version: V1.0
 * @Desc:
 * @Copyright (c) 2017 58到家-版权所有
 */
@Controller
public class DataController {
    @PostMapping("/postData")
    public @ResponseBody
    Map<String, Object> postData(String no, int quantity, String date) {
        System.out.println("no:" + no);
        System.out.println("quantity:" + quantity);
        System.out.println("date:" + date);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("msg", "ok");
        map.put("quantity", quantity);
        map.put("no", no);
        map.put("date", date);
        return map;
    }

    @PostMapping("/postJson")
    public @ResponseBody Map<String, Object> postJson(@RequestBody Order order) {
        System.out.println("order no:" + order.no);
        System.out.println("order quantity:" + order.quantity);
        System.out.println("order date:" + order.date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("msg", "ok");
        map.put("value", order);
        return map;
    }
}
